<template>
  <div class='app-container'>
    <remote-script src="javascript/flow/traceobjectclass.js"></remote-script>
    <remote-script src="javascript/flow/trace.js"></remote-script>
    <remote-script src="javascript/flow/raphael-min.js"></remote-script>
    <remote-script src="javascript/flow/tracepathcontrol.js"></remote-script>
    <remote-script src="javascript/flow/json3.js"></remote-script>
    <el-menu default-active='active' mode='horizontal' class='menu-unit'>
      <el-menu-item v-for='item in Container1' :index="'检测流程'===item.name?'active':'default'">
        <el-link @click="gotoMenu(item.url)" :type="'检测流程'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
      </el-menu-item>
    </el-menu>
    <table cellpadding="4" cellspacing="0" border="0" width="100%">
      <tr>
        <td class="containerBack">
          <el-button @click="gotoPage('/mes/product/TechnologyStatistical?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <el-button @click="popTestingItemsTech('')" type='success' size="mini"><i class='fa fa-plus'></i>增加开始工序</el-button>
          <el-button @click="d_plan_step('')" type='primary' size="mini">一键清空</el-button>
          <el-button @click="gotoPage('/mes/product/DetectionFlow1?'+vueparams+'')" type='primary' size="mini">刷新</el-button>
          <el-button @click="popChecklist1('')" type='primary' size="mini">工序列表</el-button>
          <el-button @click="detectionFlow1Submit('')" type='danger' size="mini"><i class='fa fa-check'></i>保存位置</el-button>
          <div class="form-unit">
            <span class="mvc-title-left">
              {{plan_name}}
            </span>
          </div>
          <el-form ref="form" :rules="rules" label-width="100px">
            <input id=functionName type=hidden name=functionName>
            <input id=pathInfo type=hidden value='' name=pathInfo>
            <input id=mainTableName type=hidden name=mainTableName>
            <input id=listTableName type=hidden name=listTableName>
          </el-form>
          <div id="svg"></div>
          <div id=altMsg scrolling="no" style="border:1px solid #000000 ;position: absolute; background-color: #FFFAE9; z-index: 200; font-size: 10pt; display: none"></div>
          <div id=oPopupMenu scrolling="no" style="position: absolute; z-index: 200; display: none"></div>
        </td>
      </tr>
    </table>
    <el-dialog :visible.sync="TestingItemsTechVisible" append-to-body>
      <TestingItemsTech v-if="TestingItemsTechVisible" ref="TestingItemsTech" :popparams="popparams"> </TestingItemsTech>
    </el-dialog>
    <el-dialog :visible.sync="Checklist1Visible" append-to-body>
      <Checklist1 v-if="Checklist1Visible" ref="Checklist1" :popparams="popparams"> </Checklist1>
    </el-dialog>
    <el-dialog :visible.sync="TestingItemsMangeVisible" append-to-body>
      <TestingItemsMange v-if="TestingItemsMangeVisible" ref="TestingItemsMange" :popparams="popparams"> </TestingItemsMange>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import TestingItemsTech from "@/views/mes/product/TestingItemsTech";
  import Checklist1 from "@/views/mes/product/Checklist1";
  import TestingItemsMange from "@/views/mes/product/TestingItemsMange";
  export default {
    name: 'DetectionFlow1',
    components: {
      TestingItemsTech,
      Checklist1,
      TestingItemsMange,
    },
    props: ['popparams'],
    data() {
      return {
        TestingItemsTechVisible: false,
        TestingItemsTechValue: null,
        TestingItemsTechDesc: null,
        Checklist1Visible: false,
        Checklist1Value: null,
        Checklist1Desc: null,
        TestingItemsMangeVisible: false,
        TestingItemsMangeValue: null,
        TestingItemsMangeDesc: null,
        vueparams: this.getVUEParams(""),
        loading: false,
        Container1: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "28847805EE1D403DBCD43478FD18BD08",
        name: "检测方案右菜单",
        selected: "检测流程"
      }, 'Container1', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/detectionFlow1?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
          window.m_bView = false;
          this.mvc.flowLoad(this.steps, this.skips);
          window.g_vue = this;
          for (var o in g_pathAry) {
            var emt = g_pathAry[o];
            emt.href = 'javascript:g_vue.popTestingItemsMange("&CMIDstep_id=' + emt.stepId + '")'
          }
          flowLoad();
        })
      },
      detectionFlow1Submit(_params) {
        this.$data.pathInfo = submitString("SAVE");
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/detectionFlow1Submit?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.gotoPage("/mes/product/TechnologyStatistical/technologyStatistical?" + this.vueparams, data);
          this.msgSuccess(data.msg);
        })
      },
      d_plan_step(_params) {
        this.$data.pathInfo = submitString("SAVE");
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/d_plan_step?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popTestingItemsTech(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.TestingItemsTechVisible = !this.TestingItemsTechVisible;
      },
      popChecklist1(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.Checklist1Visible = !this.Checklist1Visible;
      },
      popTestingItemsMange(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.TestingItemsMangeVisible = !this.TestingItemsMangeVisible;
      },
    },
  }
</script>
